﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Taci
{

    class ResultLi
    {
        private List<MyMat> li;

        public MyMat this[int pos]
        {
            get { return li[pos]; }
            set { li[pos] = value; }
        }

        public ResultLi()
        {
            li = new List<MyMat>();
            idList = new HashSet<int>();
        }

        public void Insert(MyMat item)
        {
            if(idList.Contains(item.id))
                return;
            idList.Add(item.id);
            
            for (int i = 0; i < li.Count; i++)
            {                

                if (item.compareVal<=li[i].compareVal)
                {
                    li.Insert(i, item);
                    return;
                }
            }
            li.Add(item);
        }
        public void Clear()
        {
            li.Clear();
            idList.Clear();
        }
        public void Remove(MyMat item)
        {
            idList.Remove(item.id);
            li.Remove(item);
        }

        public int Length
        { get { return li.Count; } }

        private HashSet<int> idList;
    }
}
